package com.mandao.oneplat.boot.support;


import com.mandao.oneplat.boot.context.OneContext;
import com.mandao.oneplat.boot.util.SecurityUtil;

import static io.netty.handler.codec.http.HttpHeaderNames.USER_AGENT;

/**
 * Created by sunson on 2017/3/23.
 */
public final class OneSessionManager {

    public static OneSession genSession(OneContext oneContext) {
        OneSession oneSession = new OneSession();
        oneSession.setIp(oneContext.getOneRequest().getIp());
        oneSession.setDeviceId(oneContext.getHttpRequest().headers().get(USER_AGENT));
        oneSession.setSid(SecurityUtil.AESEncode(oneSession.toGenString()));
        return oneSession;
    }

}
